#include "GeomMatrix.h"
#include <cmath>

algebra::Matrix4f geom::createRotationMatrixAroundX(float angle)
{
	float s = sin(angle);
	float c = cos(angle);
	algebra::Matrix4f m;
	m.at(0,0) = 1;
	m.at(1,1) = c;
	m.at(2,1) =-s;
	m.at(1,2) = s;
	m.at(2,2) = c;
	m.at(3,3) = 1;
	return m;
}

algebra::Matrix4f geom::createRotationMatrixAroundY(float angle)
{
	float s = sin(angle);
	float c = cos(angle);
	algebra::Matrix4f m;
	m.at(0,0) = c;
	m.at(1,1) = 1;
	m.at(2,0) = s;
	m.at(0,2) =-s;
	m.at(2,2) = c;
	m.at(3,3) = 1;
	return m;
}

algebra::Matrix4f geom::createRotationMatrixAroundZ(float angle)
{
	float s = sin(angle);
	float c = cos(angle);
	algebra::Matrix4f m;
	m.at(0,0) = c;
	m.at(1,1) = c;
	m.at(1,0) =-s;
	m.at(0,1) = s;
	m.at(2,2) = 1;
	m.at(3,3) = 1;
	return m;
}

algebra::Matrix4f geom::createRotationMatrixAroundVector(Vector3D vec, float angle)
{
	class NotImplementedException{};
	throw NotImplementedException();
}

algebra::Matrix4f geom::createTranslationMatrix(float x, float y, float z)
{
	algebra::Matrix4f m;
	m.at(3,0) = x;
	m.at(3,1) = y;
	m.at(3,2) = z;
	m.at(0,0) = 1;
	m.at(1,1) = 1;
	m.at(2,2) = 1;
	m.at(3,3) = 1;
	return m;
}

algebra::Matrix4f geom::createScalingMatrix(float s)
{
	algebra::Matrix4f m = algebra::identityMatrix4f();
	m*=s;
	m.at(3,3) = 1;
	return m;
}

algebra::Matrix4f geom::createScalingMatrix(float sx, float sy, float sz)
{
	algebra::Matrix4f m;
	m.at(0,0) = sx;
	m.at(1,1) = sy;
	m.at(2,2) = sz;
	m.at(3,3) = 1;
	return m;
}

